// ActionScript file
import com.helloniu.controller.UserListController;
import com.helloniu.fl.util.StyleTool;
import com.helloniu.fl.util.Tool;

import flash.media.Camera;

private var videoW:Number = 330;//110
private var videoH:Number = 260;//110

private function initApp(e:*):void {
	StyleTool.setBtnStyle(publishVideoBtn, "openCameraIcon");
    StyleTool.setBtnSStyle(publishVideoBtn, "closeCameraIcon");
}

private function publishVideo(e:*):void {
	if(!publishVideoBtn.selected) {
		UserListController.getIns().closeVideo();
    	return;
    }
    
	var cam:Camera = Camera.getCamera();
	var mic:Microphone = Microphone.getMicrophone();
    
	if(cam == null) {
    	Tool.traceT("Camera is null!");
    }

	if(mic == null) {
    	Tool.traceT("Microphone is null!");
    }

	Tool.initAV(mic, cam);

	showLocalVideo(cam);	
	UserListController.getIns().openVideo(mic, cam);
}

private function showLocalVideo(cam:Camera):void {
    // 本地视频大小
    videoW = this.width;//110
	videoH = this.height;//110

	var localVideo:Video = new Video();        
	localVideo.width = videoW;
	localVideo.height = videoH;
	localVideo.attachCamera(cam);            
	localVDShow.addChild(localVideo);
	localVDShow.width = videoW;
	localVDShow.height = videoH;
}